package modele;


import java.util.Date;
import java.util.List;
import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.persistence.Embeddable;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;

@Entity
@Table(name = "article")
@SuppressWarnings("serial")
public class Article implements Serializable {

	/**
	 * Attribute idArticle.
	 */
	private Integer idArticle;
	
	/**
	 * Attribute arRef.
	 */
	private String arRef;
	
	/**
	 * Attribute arDesign.
	 */
	private String arDesign;
	
	/**
	 * Attribute faCodefamille.
	 */
	private Famille famille;
	
	private int idFamille;
	/**
	 * Attribute arGarantie.
	 */
	private String arGarantie;
	
	/**
	 * Attribute arPoidsnet.
	 */
	private Float arPoidsnet;
	
	/**
	 * Attribute arPoidsbrut.
	 */
	private Float arPoidsbrut;
	
	/**
	 * Attribute arUniteven.
	 */
	private Short arUniteven;
	
	/**
	 * Attribute arPrixach.
	 */
	private Float arPrixach;
	
	/**
	 * Attribute arPrixven.
	 */
	private Float arPrixven;
	
	/**
	 * Attribute arPrixttc.
	 */
	private Float arPrixttc;
	
	/**
	 * Attribute arSuivistock.
	 */
	private Short arSuivistock;
	
	/**
	 * Attribute arDelai.
	 */
	private Short arDelai;
	
	/**
	 * Attribute arCodebarre.
	 */
	private String arCodebarre;
	
	/**
	 * Attribute arCodefiscal.
	 */
	private String arCodefiscal;
	
	/**
	 * Attribute arPhoto.
	 */
	private String arPhoto;
	
	/**
	 * Attribute arPrixachnouv.
	 */
	private Double arPrixachnouv;
	
	/**
	 * Attribute arPrixvennouv.
	 */
	private Double arPrixvennouv;
	
	/**
	 * Attribute arDateapplication.
	 */
	private Date arDateapplication;
	
	/**
	 * List of Articlestock
	 */
	private List<Articlestock> articlestocks;

	/**
	 * List of Articletaxe
	 */
	private List<Articletaxe> articletaxes;

	/**
	 * List of Docligne
	 */
	private List<Docligne> doclignes;

	private float valTaxe=0;
	
	/**
	 * <p> 
	 * </p>
	 * @return idArticle
	 */
	@Basic
	@Id
	@GeneratedValue
	@Column(name = "id_article")
		public Integer getIdArticle() {
		return idArticle;
	}

	/**
	 * @param idArticle new value for idArticle 
	 */
	public void setIdArticle(Integer idArticle) {
		this.idArticle = idArticle;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arRef
	 */
	@Basic
	@Column(name = "AR_Ref", length = 19)
		public String getArRef() {
		return arRef;
	}

	/**
	 * @param arRef new value for arRef 
	 */
	public void setArRef(String arRef) {
		this.arRef = arRef;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arDesign
	 */
	@Basic
	@Column(name = "AR_Design", length = 45)
		public String getArDesign() {
		return arDesign;
	}

	/**
	 * @param arDesign new value for arDesign 
	 */
	public void setArDesign(String arDesign) {
		this.arDesign = arDesign;
	}
	/**
	 * <p> 
	 * </p>
	 * @return arGarantie
	 */
	@Basic
	@Column(name = "AR_Garantie", length = 45)
		public String getArGarantie() {
		return arGarantie;
	}

	/**
	 * @param arGarantie new value for arGarantie 
	 */
	public void setArGarantie(String arGarantie) {
		this.arGarantie = arGarantie;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPoidsnet
	 */
	@Basic
	@Column(name = "AR_PoidsNet")
		public Float getArPoidsnet() {
		return arPoidsnet;
	}

	/**
	 * @param arPoidsnet new value for arPoidsnet 
	 */
	public void setArPoidsnet(Float arPoidsnet) {
		this.arPoidsnet = arPoidsnet;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPoidsbrut
	 */
	@Basic
	@Column(name = "AR_PoidsBrut")
		public Float getArPoidsbrut() {
		return arPoidsbrut;
	}

	/**
	 * @param arPoidsbrut new value for arPoidsbrut 
	 */
	public void setArPoidsbrut(Float arPoidsbrut) {
		this.arPoidsbrut = arPoidsbrut;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arUniteven
	 */
	@Basic
	@Column(name = "AR_UniteVen")
		public Short getArUniteven() {
		return arUniteven;
	}

	/**
	 * @param arUniteven new value for arUniteven 
	 */
	public void setArUniteven(Short arUniteven) {
		this.arUniteven = arUniteven;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPrixach
	 */
	@Basic
	@Column(name = "AR_PrixAch")
		public Float getArPrixach() {
		return arPrixach;
	}

	/**
	 * @param arPrixach new value for arPrixach 
	 */
	public void setArPrixach(Float arPrixach) {
		this.arPrixach = arPrixach;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPrixven
	 */
	@Basic
	@Column(name = "AR_PrixVen")
		public Float getArPrixven() {
		return arPrixven;
	}

	/**
	 * @param arPrixven new value for arPrixven 
	 */
	public void setArPrixven(Float arPrixven) {
		this.arPrixven = arPrixven;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPrixttc
	 */
	@Basic
	@Column(name = "AR_PrixTTC")
		public Float getArPrixttc() {
		return arPrixttc;
	}

	/**
	 * @param arPrixttc new value for arPrixttc 
	 */
	public void setArPrixttc(Float arPrixttc) {
		this.arPrixttc = arPrixttc;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arSuivistock
	 */
	@Basic
	@Column(name = "AR_SuiviStock")
		public Short getArSuivistock() {
		return arSuivistock;
	}

	/**
	 * @param arSuivistock new value for arSuivistock 
	 */
	public void setArSuivistock(Short arSuivistock) {
		this.arSuivistock = arSuivistock;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arDelai
	 */
	@Basic
	@Column(name = "AR_Delai")
		public Short getArDelai() {
		return arDelai;
	}

	/**
	 * @param arDelai new value for arDelai 
	 */
	public void setArDelai(Short arDelai) {
		this.arDelai = arDelai;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arCodebarre
	 */
	@Basic
	@Column(name = "AR_CodeBarre", length = 19)
		public String getArCodebarre() {
		return arCodebarre;
	}

	/**
	 * @param arCodebarre new value for arCodebarre 
	 */
	public void setArCodebarre(String arCodebarre) {
		this.arCodebarre = arCodebarre;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arCodefiscal
	 */
	@Basic
	@Column(name = "AR_CodeFiscal", length = 25)
		public String getArCodefiscal() {
		return arCodefiscal;
	}

	/**
	 * @param arCodefiscal new value for arCodefiscal 
	 */
	public void setArCodefiscal(String arCodefiscal) {
		this.arCodefiscal = arCodefiscal;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPhoto
	 */
	@Basic
	@Column(name = "AR_Photo", length = 50)
		public String getArPhoto() {
		return arPhoto;
	}

	/**
	 * @param arPhoto new value for arPhoto 
	 */
	public void setArPhoto(String arPhoto) {
		this.arPhoto = arPhoto;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPrixachnouv
	 */
	@Basic
	@Column(name = "AR_PrixAchNouv")
		public Double getArPrixachnouv() {
		return arPrixachnouv;
	}

	/**
	 * @param arPrixachnouv new value for arPrixachnouv 
	 */
	public void setArPrixachnouv(Double arPrixachnouv) {
		this.arPrixachnouv = arPrixachnouv;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arPrixvennouv
	 */
	@Basic
	@Column(name = "AR_PrixVenNouv")
		public Double getArPrixvennouv() {
		return arPrixvennouv;
	}

	/**
	 * @param arPrixvennouv new value for arPrixvennouv 
	 */
	public void setArPrixvennouv(Double arPrixvennouv) {
		this.arPrixvennouv = arPrixvennouv;
	}
	
	/**
	 * <p> 
	 * </p>
	 * @return arDateapplication
	 */
	@Basic
	@Column(name = "AR_DateApplication")
		public Date getArDateapplication() {
		return arDateapplication;
	}

	/**
	 * @param arDateapplication new value for arDateapplication 
	 */
	public void setArDateapplication(Date arDateapplication) {
		this.arDateapplication = arDateapplication;
	}
	
	/**
	 * Get the list of Articlestock
	 */
	 @OneToMany(mappedBy="article",fetch=FetchType.LAZY)
	 @JsonIgnore
	 public List<Articlestock> getArticlestocks() {
	 	return this.articlestocks;
	 }
	 
	/**
	 * Set the list of Articlestock
	 */
	 public void setArticlestocks(List<Articlestock> articlestocks) {
	 	this.articlestocks = articlestocks;
	 }
	/**
	 * Get the list of Articletaxe
	 */
	 @OneToMany(mappedBy="article",fetch=FetchType.LAZY)
	 @JsonIgnore
	 public List<Articletaxe> getArticletaxes() {
	 	return this.articletaxes;
	 }
	 
	/**
	 * Set the list of Articletaxe
	 */
	 public void setArticletaxes(List<Articletaxe> articletaxes) {
	 	this.articletaxes = articletaxes;
	 }
	/**
	 * Get the list of Docligne
	 */
	 @OneToMany(mappedBy="article",fetch=FetchType.LAZY)
	 @JsonIgnore
	 public List<Docligne> getDoclignes() {
	 	return this.doclignes;
	 }
	 
	/**
	 * Set the list of Docligne
	 */
	 public void setDoclignes(List<Docligne> doclignes) {
	 	this.doclignes = doclignes;
	 }

	public void setValTaxe(float valTaxe) {
		this.valTaxe = valTaxe;
	}
	
	
	@Transient
	public float getValTaxe() {
		if((articletaxes!=null) && (articletaxes.size()>0))
			return articletaxes.get(0).getTaxe().getTaTaux();
		else
			return 0;
	}

	public void setFamille(Famille famille) {
		this.famille = famille;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JsonIgnore
	@JoinColumn(name = "id_famille",insertable=false ,updatable=false)
	public Famille getFamille() {
		return famille;
	}

	public void setIdFamille(int idFamille) {
		this.idFamille = idFamille;
	}

	@Basic
	@Column(name = "id_famille")
	public int getIdFamille() {
		return idFamille;
	}
}